package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProductUse;
import com.ruoyi.system.service.IProductUseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 备品使用Controller
 * 
 * @author winner pan
 * @date 2022-03-17
 */
@RestController
@RequestMapping("/system/productUse")
public class ProductUseController extends BaseController
{
    @Autowired
    private IProductUseService productUseService;

    /**
     * 查询备品使用列表
     */
   // @PreAuthorize("@ss.hasPermi('system:productUse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductUse productUse)
    {
        startPage();
        List<ProductUse> list = productUseService.selectProductUseList(productUse);
        return getDataTable(list);
    }

    /**
     * 导出备品使用列表
     */
    //@PreAuthorize("@ss.hasPermi('system:productUse:export')")
    @Log(title = "备品使用", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProductUse productUse)
    {
        List<ProductUse> list = productUseService.selectProductUseList(productUse);
        ExcelUtil<ProductUse> util = new ExcelUtil<ProductUse>(ProductUse.class);
        return util.exportExcel(list, "productUse");
    }

    /**
     * 获取备品使用详细信息
     */
   // @PreAuthorize("@ss.hasPermi('system:productUse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(productUseService.selectProductUseById(id));
    }

    /**
     * 新增备品使用
     */
   // @PreAuthorize("@ss.hasPermi('system:productUse:add')")
    @Log(title = "备品使用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductUse productUse)
    {
        return toAjax(productUseService.insertProductUse(productUse));
    }

    /**
     * 修改备品使用
     */
   /* @PreAuthorize("@ss.hasPermi('system:productUse:edit')")
    @Log(title = "备品使用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductUse productUse)
    {
        return toAjax(productUseService.updateProductUse(productUse));
    }
*/
    /**
     * 删除备品使用
     */
   //@PreAuthorize("@ss.hasPermi('system:productUse:remove')")
    @Log(title = "备品使用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long ids)
    {
        return toAjax(productUseService.deleteProductUseById(ids));
    }
}